//题目链接：https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf?tpId=230&tqId=38960&ru=/exam/oj
#include <iostream>
using namespace std;
const int N =  1e6 + 10;
long long a[N],s[N];
int n , m;

int main() {
    scanf("%d%d",&n,&m);
    for(int i = 1 ; i <= n ; ++i) scanf("%lld",&a[i]),s[i] = s[i-1] + a[i];
    while(m--)
    {
        int l , r;
        scanf("%d%d",&l,&r);
        printf("%lld\n",s[r] - s[l-1]);
    }
    return 0;
}
// 64 位输出请用 printf("%lld")